< previous page page_395 next page >

Page 395
found embedded directly in a Web page, as is JavaScript. In the following sections, you'll get a brief overview of VBScript and how to use it, as well as some notes on how it varies from the standard Visual Basic language.
VBScript Overview
VBScript was designed to be a subset of the full Visual Basic language because its code is interpreted as the Web page is displayed. As you already know, the HTML code behind a Web page can also include scripting code to enhance the Web page. Before the introduction of VBScript, JavaScript had established itself as the industry standard for Web page scripting; however, JavaScript is very similar to C++, which made it difficult for VB programmers to use.
The main purpose for Microsoft's developing VBScript was to provide a Web scripting language compatible with Microsoft's industry standard for Windows development, Visual Basic. Because this new language was going to be embedded into Web pages, it needed to be simple enough that it could be interpreted as quickly as JavaScript. To accomplish this, the Visual Basic language needed to be simplified.
VBScript also was scaled down from Visual Basic for security concerns. If VBScript programmers could call the Windows API or perform file I/O, hackers could easily write a virus in VBScript to crash every system that executed their VBScript Web page. To reduce the chances of this happening, all the features of Visual Basic that potentially could be abused were removed.
Perhaps the biggest difference (and source of frustration) between VBScript and standard Visual Basic is that VBScript supports only the Variant data type. This means that a statement such as:
Dim x As Integer
would trigger an error in VBScript because the Integer data type isn't supported. Using just the Variant data type simplifies the code for the interpreter, thus making execution much faster.
When you start working with VBScript, knowing what commands and features of Visual Basic aren't supported is a good idea. This keeps you from designing a function that can't be coded in VBScript. Table 14.6 lists the features that you can't use in VBScript code.

 
< previous page page_395 next page >

If you like this book, buy it!